package com.tamtoucan.tameablecreepers;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class RenderTameableCreeper extends RenderLiving {
	private static final ResourceLocation creeperTextures = new ResourceLocation(
			"textures/entity/creeper/creeper.png");
	private static final ResourceLocation tamedTextures = new ResourceLocation(ModConstants.MOD_ID, "textures/model/tamed_creeper.png");
	
	/** The creeper model. */
	private ModelBase creeperModel = new ModelTameableCreeper(2.0F);

	public RenderTameableCreeper() {
		super(new ModelTameableCreeper(), 0.5F);
		this.setRenderPassModel(this.creeperModel);
	}

	/**
	 * A method used to render a creeper's powered form as a pass model.
	 */
	protected int renderCreeperPassModel(
			EntityTameableCreeper par1EntityCreeper, int par2, float par3) {
		return -1;
	}

	protected int func_77061_b(EntityTameableCreeper par1EntityCreeper,
			int par2, float par3) {
		return -1;
	}

	protected ResourceLocation getCreeperTextures(
			EntityTameableCreeper par1EntityCreeper) {
		return par1EntityCreeper.isTamed() ? tamedTextures : creeperTextures;
	}

	/**
	 * Allows the render to do any OpenGL state modifications necessary before
	 * the model is rendered. Args: entityLiving, partialTickTime
	 */
	protected void preRenderCallback(EntityLivingBase par1EntityLivingBase,
			float par2) {
	}

	/**
	 * Queries whether should render the specified pass or not.
	 */
	protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase,
			int par2, float par3) {
		return this.renderCreeperPassModel(
				(EntityTameableCreeper) par1EntityLivingBase, par2, par3);
	}

	protected int inheritRenderPass(EntityLivingBase par1EntityLivingBase,
			int par2, float par3) {
		return this.func_77061_b((EntityTameableCreeper) par1EntityLivingBase,
				par2, par3);
	}

	/**
	 * Returns the location of an entity's texture. Doesn't seem to be called
	 * unless you call Render.bindEntityTexture.
	 */
	protected ResourceLocation getEntityTexture(Entity par1Entity) {
		return this.getCreeperTextures((EntityTameableCreeper) par1Entity);
	}
}
